package org.jeecg.glr.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.glr.entity.GlrVideo;
import org.jeecg.glr.entity.GlrVideoBdResource;
import org.jeecg.glr.entity.GlrVideoBdURRelation;
import org.jeecg.glr.mapper.GlrVideoBdURRelationMapper;
import org.jeecg.glr.mapper.GlrVideoMapper;
import org.jeecg.glr.service.IGlrVideoBdURRelationService;
import org.jeecg.glr.service.IGlrVideoService;
import org.springframework.stereotype.Service;
import org.jeecg.glr.util.StringUtil;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 海康摄像头
 * @Author: jeecg-boot
 * @Date:   2020-02-11
 * @Version: V1.0
 */
@Service
public class GlrVideoBdURRelationServiceImpl extends ServiceImpl<GlrVideoBdURRelationMapper, GlrVideoBdURRelation> implements IGlrVideoBdURRelationService {

    @Resource
    GlrVideoBdURRelationMapper glrVideoBdURRelationMapper;

    @Override
    public void bingResource(GlrVideoBdURRelation domain){
        if(StringUtil.isNotEmpty(domain.getIds())){
            String [] ids=domain.getIds().split(",");
            for(int i=0;i<ids.length;i++){
                if(StringUtil.isNotEmpty(ids[i])){
                    GlrVideoBdURRelation r = new GlrVideoBdURRelation();
                    r.setResourceId(ids[i]);
                    r.setUserId(domain.getUserId());
                    super.save(r);
                }
            }
        }
    }

    @Override
    public  List<String> getResourceByUserId(String userId){
        return glrVideoBdURRelationMapper.getResourceByUserId(userId);
    }
}
